import jieba

from pymongo import MongoClient

mogo = MongoClient(host="127.0.0.1", port=27017)
db = mogo.h2111a
data = db.h2111a.find()
text = "过去终究是过去，过去的遗憾不能填补"
for i in data:
    print(i)
list1 = jieba.cut(text, cut_all=False)

db.h2111a.insert_one({"name": "kunkun", "info": text, "kw": list(list1)})



from flask import Flask, request, jsonify

app = Flask(__name__)


@app.get("/msg")
def goods():
    name = request.args.get("name")
    price = request.args.get("price")
    color = request.args.get("color")
    db.price.insert_one({"name": name, "price": price, "text": list(get_word(color))})
    return jsonify({"name": name, "price": price, "color": color})


@app.get("/find")
def find():
    color = request.args.get("color")
    ret = db.msg.find({"$text": {"$search": color}}, {"_id": 0, "text": 0})
    return ret


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=9527)
